This folder contains the data and code for replication of main and supplementary figures, tables and some analyses presented in Fan et al. 2021, "Solar geoengineering can alleviate climate change pressures on crop yields." Nature Food 2(5). DOI: 10.1038/s43016-021-00278-w
Authors: Yuanchao Fan*, Jerry Tjiputra, Helene Muri, Danica Lombardozzi, ChangEui Park, Shengjun Wu, David Keith

Users of these data should cite Fan et al. (2021). Please contact Yuanchao Fan (ycfan@seas.harvard.edu or yfansunny@gmail.com) for any questions. 

##Description of the folder structure below (please change to Tree view after openning the Dataverse link)
##relative paths to the input data and output figures are according to the below structure
##the absolute top level path should be set to the replication folder after downloaded to your local directory  

==data (Stores intermediate data to be read by scripts and some raw data)
---climate_data (raw climate data simulated by NorESM1-ME for SAI, MSB, CCT, RCP45 and RCP85)
---faostat (FAO yield data for CLM5 crop validation; main Figure 2)
---land_cover (land cover data including land area and crop fractions in each grid cell) 
---NCL (intermediate data for NCL scripts)
---RData (intermediate data for R scripts)
---yield_data (raw and processed yield data simulated by CLM5-crop for different climate and land use scenarios)

==figures (Output figures presented in the paper)
---extended (Extended Data Figures 1-4)
---main (main Figures 1-5)
---supplementary (Supplementary Figures 1-11)

==scripts (Stores NCL and R scripts for replicating the figures and some analyses)
---NCL (scripts for main Figure 5, supplementary Figures 2, 7-8, and for preparing global gridded yield data from raw model output)
---R (scripts for main Figures 1-4, Extended Data Figures 1-4, and supplementary Figures 1, 3-6, 9-11, and for preparing intermediate R data)

==tables (Excel sheets for preparing the Supplementary Table 2)


##Instructions 
All figures can be replicated by running the figure scripts one by one (scripts named "Fig.***" in the NCL and R subdirectories). Each figure script may contain some intermediate steps to further process the data before making plots. Whenever possible, there are readRDS("***.Rds") or load("***.Rdata") functions to read existing intermediate data (prepared by individual data scripts) right before the plotting code in the R scripts. 

Users do not need to rerun the data scripts (scripts named "Data***" for both NCL and R) which generate the intermediate data in the data folder. Some data scripts need to read raw climate and yield data from the simulations in netCDF format which are too large for this repository. They can be made available upon request.

If you find any error in the scripts, please do not hesitate to contact Yuanchao Fan.